package org.superheroes.androidserver.io;

import java.io.FileInputStream;
import java.io.InputStream;

public class VideoStream {
	private FileInputStream fis = null;

	public VideoStream(String filename) throws Exception {
		fis = new FileInputStream("/data/" + filename);
	}

	public int getNextFrame(byte[] frame) throws Exception {
		int length = 0;
		String lengthString;
		byte[] frameLength = new byte[5];

		fis.read(frameLength, 0, 5);

		lengthString = new String(frameLength);
		length = Integer.parseInt(lengthString);

		return fis.read(frame, 0, length);

	}
	
	public void setFis(FileInputStream fis) {
		this.fis = fis;
	}
}
